package servlet.customer.api;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import util.JsonUtil;
import data.VersionTable;
import dto.StatusVersionDto;

public class GetSuccessStatusVersionServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	private VersionTable versionTable;
       
    public GetSuccessStatusVersionServlet() {
        super();
        versionTable = VersionTable.getInstance();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		  response.setHeader("Access-Control-Allow-Origin", "*");
		  StatusVersionDto sVersionDto = new StatusVersionDto();
		  sVersionDto.setVersion(versionTable.get(VersionTable.STATUS_CHANGE__VERSION));
		  PrintWriter writer = response.getWriter();
		  writer.write(JsonUtil.toJsonString(sVersionDto));
		  writer.close();
	      
	}

}
